#include <cstdio>
#include <iostream>
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;
int n;

inline ll mul(ll x, int k) {
	ll res = 1;
	while (k) {
		if (k & 1) {
			res *= x;
			res %= mod;
		}
		(x *= x) %= mod;
		k >>= 1;
	}
	return res;
}

int main() {
	freopen("magic.in", "r", stdin);
	freopen("magic.out", "w", stdout);
	scanf("%d", &n);
	cout << (mul(3, n + 1) - 1) * mul(2, mod - 2) % mod;
	fclose(stdin);
	fclose(stdout);
	return 0;
}